import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '*',
    redirect: '/login'
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('../views/pages/login/Login'),
    meta: {
      title: '京东登录注册'
    }
  },
  {
    path: '/city',
    name: 'cityList',
    component: () => import('../views/common/cityList/cityList'),
    meta: {
      title: '选择国家或者地区'
    }
  }
]

const router = new VueRouter({
  routes,
  // 滚动行为
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return { x: 0, y: 0 }
    }
  }
})

export default router
